/*
 * @Descripttion:
 * @Author: YuZhenJing
 * @Date: 2020-01-02 18:13:03
 * @LastEditors: YuZhenJing
 * @LastEditTime: 2020-03-20 16:04:06
 */
window.asm = {}

window.asm.theme = {
  themeValue: 'theme-default',
  themeObj: {},
  changeTheme: function(themeValue) {
    window.asm.theme.themeValue = themeValue
    var headList = document.getElementsByTagName('head')[0].childNodes
    for (var number = 0; number < headList.length; number++) {
      var headChild = headList[number]
      if (headChild.nodeName == 'LINK') {
        let newHref = headChild.href
        let newTheme = '/' + themeValue.replace('theme-', '') + '/'
        if (newHref.indexOf('css/theme/default/index.css') != -1) {
          if (themeValue != 'theme-default') {
            headChild.href = newHref.replace('/default/', newTheme)
          }
        } else if (newHref.indexOf('css/theme/cg/index.css') != -1) {
          if (themeValue != 'theme-cg') {
            headChild.href = newHref.replace('/cg/', newTheme)
          }
        }
      }
    }
  }
}
